package seqlist.leetcode;

/**
 * 判断链表是否带环
 * @author yuisama
 * @date 2022/04/24 20:57
 **/
public class Num141_HasCycle {
    public boolean hasCycle(ListNode head) {
        ListNode fast = head;
        ListNode low = head;
        while (fast != null && fast.next != null) {
            fast = fast.next.next;
            low = low.next;
            if (fast == low) {
                return true;
            }
        }
        // 直线
        return false;
    }
}